package com.study.array;

import java.util.Arrays;

/**
 * @author ytj
 * @date 2021/12/27
 */
public class Method7 {
    public static void main(String[] args) {
        int[] nums={1,2,3,4,5,6,7};
        int k=3;
        rotate(nums,k);
        Arrays.stream(nums).forEach(System.out::println);
    }

    public static void rotate(int[] nums,int key){
        int length=nums.length;
        int[] newNums=Arrays.copyOf(nums,length);
        for(int i=0;i<length;i++){
            nums[(i+key)%length]=newNums[i];
        }
    }
}
